package k2_oop.p9_collection.demo06;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class StudentSort {
    public static void main(String[] args) {

        ArrayList<Student> stus = new ArrayList<>();
        stus.add(new Student("jerry",20));
        stus.add(new Student("波波",50));
        stus.add(new Student("kitty",10));
        stus.add(new Student("jerry",40));
        stus.add(new Student("波波",30));

        System.out.println(stus);

        Collections.sort(stus, (s1,s2) -> s2.getAge()-s1.getAge());
        System.out.println(stus);
        Collections.sort(stus, (s1,s2) -> s1.getName().compareTo(s2.getName()));
        System.out.println(stus);


    }
}
